package cn.edu.usts.controller;

import cn.edu.usts.pojo.User;
import cn.edu.usts.service.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {
    @Autowired
    private UserServiceImpl userService;

    @ResponseBody
    @RequestMapping(value="/addUser",method = RequestMethod.POST)
    public int addUser(User user){
        return userService.addUser(user);
    }

    @ResponseBody
    @RequestMapping("/deleteUser")
    public int deleteUser(Integer id){
        return userService.deleteUser(id);
    }

    @ResponseBody
    @RequestMapping("/updateUser")
    public int updateUser(User user){
        return userService.updateUser(user);
    }

    @ResponseBody
    @RequestMapping("/queryUser")
    public String queryUser(Integer id){
        User user = userService.queryUser(1);
        return user.toString();

    }

}
